package com.bolt.admin.codegenerator;


import com.bolt.support.codegenerator.model.Table;

/**
 * 代码生成
 * Created by michao on 2018/11/5.
 */
public class CodeHelper {

    private static String JDBC_URL = "jdbc:mysql://bj-cdb-0x0ztp39.sql.tencentcdb.com:63812/bolt_db?useUnicode=true&characterEncoding=utf-8";

    private static String JDBC_USER = "root";

    private static String JDBC_PASSWORD = "yyzn@dangzl";

    private static String JDBC_DRIVER = "com.mysql.jdbc.Driver";

    private CodeGeneratorService sourceCodeBuilder;

    String rootDir1 = "D:\\myworkspace\\bolt-parent\\bolt-springboot\\src\\main\\java";

    public CodeHelper() {

        sourceCodeBuilder = new CodeGeneratorService(JDBC_URL, JDBC_USER, JDBC_PASSWORD, JDBC_DRIVER);
    }

    public void codeGenerator(String tableName) {
        try {
            Table table = sourceCodeBuilder.getTable(tableName);

            sourceCodeBuilder.generatorRestController(table, rootDir1, "com.bolt.admin.web.rest", table.getClassName() + "Controller.java");
//            sourceCodeBuilder.generatorService(table, rootDir1, "com.bolt.admin.module.dict", table.getClassName() + "Service.java");
//            sourceCodeBuilder.generatorEntityByTable(table, rootDir1, "com.bolt.admin.module.dict", table.getClassName() + "Entity.java");
//            sourceCodeBuilder.generatorRepository(table, rootDir1, "com.bolt.admin.module.dict", table.getClassName() + "Repository.java");
//
//           sourceCodeBuilder.generatorDTOByTable(table, rootDir1, "com.bolt.admin.module.dict", table.getClassName() + "DTO.java");
//           sourceCodeBuilder.generatorConverterByTable(table, rootDir1, "com.bolt.admin.module.dict", table.getClassName() + "Converter.java");

        } catch (Exception ex) {
            ex.printStackTrace();
        }

    }

    public static void main(String[] args) {
        CodeHelper helper = new CodeHelper();
        helper.codeGenerator("sys_log");
        helper.codeGenerator("sys_quartz_job");
        helper.codeGenerator("sys_log");
        helper.codeGenerator("sys_email_config");
        helper.codeGenerator("sys_quartz_log");


    }
}
